package com.future.direction.ui.activity;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.future.direction.R;
import com.future.direction.common.util.UIUtil;
import com.future.direction.di.component.AppComponent;
import com.future.direction.interfaces.OnItemClickListener;
import com.future.direction.ui.adapter.VipAdapter;
import com.future.direction.ui.adapter.VipPowerAdapter;
import com.future.direction.ui.adapter.VipQuestionAdapter;
import com.future.direction.ui.widget.CircleImageView;
import com.future.direction.ui.widget.MyTitleBar;

import butterknife.BindView;

/**
 * Created by zhp on 2019-11-08
 */
public class VipActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.titleBar)
    MyTitleBar titleBar;
    @BindView(R.id.circle_head)
    CircleImageView circleHead;
    @BindView(R.id.tv_vip_name)
    TextView tvVipName;
    @BindView(R.id.tv_vip_date)
    TextView tvVipDate;
    @BindView(R.id.recycle_vip)
    RecyclerView recycleVip;
    @BindView(R.id.button_buy)
    Button buttonBuy;
    @BindView(R.id.recycle_power)
    RecyclerView recyclePower;
    @BindView(R.id.recycle_question)
    RecyclerView recycleQuestion;
    private VipAdapter vipAdapter;

    @Override
    public int setLayout() {
        return R.layout.activity_vip;
    }

    @Override
    public void getExtras() {

    }

    @Override
    public boolean init() {
        initRecycle();
        return false;
    }

    @Override
    public void setListener() {
        backListener(titleBar);
        buttonBuy.setOnClickListener(this);
        vipAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                vipAdapter.setPosition(position);
                vipAdapter.notifyDataSetChanged();
            }
        });
    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

    private void initRecycle() {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(UIUtil.getContext(), 3, GridLayoutManager.VERTICAL, false);
        recycleVip.setLayoutManager(gridLayoutManager);
        vipAdapter = new VipAdapter();
        recycleVip.setAdapter(vipAdapter);

        GridLayoutManager gridLayoutManager2 = new GridLayoutManager(UIUtil.getContext(), 3, GridLayoutManager.VERTICAL, false);
        recyclePower.setLayoutManager(gridLayoutManager2);
        VipPowerAdapter vipPowerAdapter = new VipPowerAdapter();
        recyclePower.setAdapter(vipPowerAdapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(UIUtil.getContext(), LinearLayoutManager.VERTICAL, false);
        recycleQuestion.setLayoutManager(linearLayoutManager);
        VipQuestionAdapter vipQuestionAdapter = new VipQuestionAdapter();
        recycleQuestion.setAdapter(vipQuestionAdapter);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button_buy:
                startActivity(new Intent(UIUtil.getContext(), RechargeActivity.class));
                break;
        }
    }
}